﻿/*****************************************************************//**
 * @file    VAOneXMLAdaptorSpectra.h
 * @brief   VAOne读写频谱适配器
 *
 * @author  lilongyuan (lilongyuan@diso.cn)
 * @date    2025-02-13
 *********************************************************************/
#ifndef VAONEXMLADAPTORSPECTRA_H
#define VAONEXMLADAPTORSPECTRA_H

#include "FITKAbstractVAOneXMLAdaptor.h"

namespace Acoustics
{
    class FITKAcousticsAbstractSpectra;
}

namespace IO
{
    /**
     * @brief   VAOne读写频谱适配器
     * @author  lilongyuan (lilongyuan@diso.cn)
     * @date    2025-02-13
     */
    class FITKVAOneXMLIOAPI VAOneXMLAdaptorSpectra : public FITKAbstractVAOneXMLAdaptor
    {
        FITKCLASS(IO, VAOneXMLAdaptorSpectra);
    public:
        /**
         * @brief   构造函数
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-13
         */
        explicit VAOneXMLAdaptorSpectra() = default;
        /**
         * @brief   析构函数
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-13
         */
        ~VAOneXMLAdaptorSpectra() = default;
        /**
         * @brief   适配器读数据
         * @return  是否执行成功
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-13
         */
        bool adaptR() override;
        /**
         * @brief   适配器写数据
         * @return  是否执行成功
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-13
         */
        bool adaptW() override;
    private:
        /**
         * @brief     读取真实光谱数据
         * @param[i]  node RealSpectrum节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool readRealSpectrum(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取复合光谱数据
         * @param[i]  node ComplexSpectrum节点
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool readComplexSpectrum(rapidxml::xml_node<char>* node);
        /**
         * @brief     读取尺寸数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool readDimensions(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     读取频率数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool readFrequencyDomain(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     读取实部值数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool readReal(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     根据频谱类型值获取频谱数据
         * @param[i]  type 频谱类型值
         * @return    Acoustics::FITKAcousticsAbstractSpectra*
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        Acoustics::FITKAcousticsAbstractSpectra* getSpectraByType(int type);
    private:
        /**
         * @brief     写出真实光谱数据
         * @param[i]  node Spectra节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool writeRealSpectrum(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     写出复合光谱数据
         * @param[i]  node Spectra节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool writeComplexSpectrum(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     根据数据对象获取频谱类型值
         * @param[i]  data 频谱数据对象
         * @return    int
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        int getTypeBySpectra(Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     写出尺寸数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool writeDimensions(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     写出频率数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool writeFrequencyDomain(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
        /**
         * @brief     写出实部值数据
         * @param[i]  node RealSpectrum节点，data 频谱数据对象
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-14
         */
        bool writeReal(rapidxml::xml_node<char>* node, Acoustics::FITKAcousticsAbstractSpectra* data);
    };

    Register2FITKIOAdaptorFactory(VAOneXML, Spectra, VAOneXMLAdaptorSpectra)
}

#endif // VAONEXMLADAPTORSPECTRA_H
